﻿Public Class frmOption
    Private Sub frmOption_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        AddHandler cmdCancel.Click, Sub()
                                        Me.Close()
                                    End Sub

        Me.txtAuthor.Text = MyConfig.Author
        Me.txtSourceComputerName.Text = MyConfig.SOURCEComputerName
        Me.txtObjectComputerName.Text = MyConfig.OBJECTComputerName
        Me.chkHasNumber.Checked = MyConfig.HasNumberInDoc
        Me.chkCreateFileStatus.Checked = MyConfig.IsCreateFileStatus

        Me.txtCopyBook.Text = MyConfig.CopyInfoFileName
        Me.txtCopyBookSource.Text = MyConfig.CopySourceFolder
        Me.txtCopyBookXML.Text = MyConfig.CopyXMLFolder
        Me.txtErrorReport.Text = MyConfig.ErrorReportName
        Me.txtFileInfo.Text = MyConfig.FileInfoFileName
        Me.txtLogFile.Text = MyConfig.LogFileName

    End Sub
    ''' <summary>
    ''' 文件情报编辑
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub cmdFileInfoEditor_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdFileInfoEditor.Click
        MyConfig.FileInfoFileName = Me.txtFileInfo.Text
        Using mfrmFileInfo As New frmFileInfo()
            mfrmFileInfo.ShowDialog()
        End Using
    End Sub
    ''' <summary>
    ''' Copy句情报编辑
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub cmdCopyBookEditor_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCopyBookEditor.Click
        MyConfig.CopyInfoFileName = txtCopyBook.Text
        MyConfig.CopyXMLFolder = txtCopyBookXML.Text
        MyConfig.CopySourceFolder = txtCopyBookSource.Text
        Using mfrmCopyBook As New frmCopyBook()
            mfrmCopyBook.ShowDialog()
        End Using
    End Sub
    ''' <summary>
    ''' Log文件
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub cmdLogFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdLogFile.Click
        Using mOpenFileDialog As New OpenFileDialog
            If mOpenFileDialog.ShowDialog = Windows.Forms.DialogResult.OK Then
                txtLogFile.Text = mOpenFileDialog.FileName
            End If
        End Using
    End Sub
    ''' <summary>
    ''' 文件信息
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub cmdFileInfo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdFileInfo.Click
        Using mOpenFileDialog As New OpenFileDialog
            If mOpenFileDialog.ShowDialog = Windows.Forms.DialogResult.OK Then
                txtFileInfo.Text = mOpenFileDialog.FileName
            End If
        End Using
    End Sub
    ''' <summary>
    ''' CopyBook信息
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub cmdCopyBook_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCopyBook.Click
        Using mOpenFileDialog As New OpenFileDialog
            If mOpenFileDialog.ShowDialog = Windows.Forms.DialogResult.OK Then
                txtCopyBook.Text = mOpenFileDialog.FileName
            End If
        End Using
    End Sub

    ''' <summary>
    ''' 错误报告
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub cmdErrorReport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdErrorReport.Click
        Using mOpenFileDialog As New OpenFileDialog
            If mOpenFileDialog.ShowDialog = Windows.Forms.DialogResult.OK Then
                txtErrorReport.Text = mOpenFileDialog.FileName
            End If
        End Using
    End Sub
    ''' <summary>
    ''' COPY句XML文件夹
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub cmdCopyXMLFolder_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCopyXMLFolder.Click
        Using mOpenFolderDialog As New FolderBrowserDialog
            If mOpenFolderDialog.ShowDialog = Windows.Forms.DialogResult.OK Then
                txtCopyBookXML.Text = mOpenFolderDialog.SelectedPath
            End If
        End Using
    End Sub
    ''' <summary>
    ''' COPY句SRC文件夹
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub cmdCopySourceFolder_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCopySourceFolder.Click
        Using mOpenFolderDialog As New FolderBrowserDialog
            If mOpenFolderDialog.ShowDialog = Windows.Forms.DialogResult.OK Then
                txtCopyBookSource.Text = mOpenFolderDialog.SelectedPath
            End If
        End Using
    End Sub
    Private Sub cmdOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdOK.Click
        MyConfig.Author = Me.txtAuthor.Text
        MyConfig.SOURCEComputerName = Me.txtSourceComputerName.Text
        MyConfig.OBJECTComputerName = Me.txtObjectComputerName.Text
        MyConfig.HasNumberInDoc = Me.chkHasNumber.Checked
        MyConfig.IsCreateFileStatus = Me.chkCreateFileStatus.Checked


        MyConfig.CopyInfoFileName = Me.txtCopyBook.Text
        MyConfig.CopySourceFolder = Me.txtCopyBookSource.Text
        MyConfig.CopyXMLFolder = Me.txtCopyBookXML.Text
        MyConfig.ErrorReportName = Me.txtErrorReport.Text
        MyConfig.FileInfoFileName = Me.txtFileInfo.Text
        MyConfig.LogFileName = Me.txtLogFile.Text
        IOSystemBase.WriteObjectToXMLFile(MyConfig, GetType(clsConfig), Application.StartupPath & "\Config.xml")
        Me.Close()
    End Sub
End Class